From c2adbbd7cbb85e83a0c6841c4440d8ad919ad24d Mon Sep 17 00:00:00 2001 From: "awilliam@xenbuild.aw" Date: Tue, 17 Oct 2006 14:22:08 -0600 Subject: [PATCH] [IA64] micro optimize __domain_flush_vtlb_track_entry. try to use local purge instead of global purge when possible. Signed-off-by: Isaku Yamahata --- xen/arch/ia64/xen/vhpt.c | 25 ++++++++++++++++++++++--- xen/include/asm-ia64/perfc_defn.h | 2 ++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/xen/arch/ia64/xen/vhpt.c b/xen/arch/ia64/xen/vhpt.c index 7630e57ff9..ecc7269a69 100644 --- a/xen/arch/ia64/xen/vhpt.c +++ b/xen/arch/ia64/xen/vhpt.c @@ -381,7 +381,8 @@ __domain_flush_vtlb_track_entry(struct domain* d, struct vcpu* v; int cpu; int vcpu; - + int local_purge = 1; + BUG_ON((vaddr >> VRN_SHIFT) != VRN7); /* * heuristic: @@ -414,17 +415,35 @@ __domain_flush_vtlb_track_entry(struct domain* d, /* Invalidate VHPT entries. */ vcpu_flush_vhpt_range(v, vaddr, PAGE_SIZE); + + /* + * current->processor == v->processor + * is racy. we may see old v->processor and + * a new physical processor of v might see old + * vhpt entry and insert tlb. + */ + if (v != current) + local_purge = 0; } } else { for_each_cpu_mask(cpu, entry->pcpu_dirty_mask) { /* Invalidate VHPT entries. */ cpu_flush_vhpt_range(cpu, vaddr, PAGE_SIZE); + + if (d->vcpu[cpu] != current) + local_purge = 0; } } - /* ptc.ga has release semantics. */ /* ptc.ga */ - ia64_global_tlb_purge(vaddr, vaddr + PAGE_SIZE, PAGE_SHIFT); + if (local_purge) { + ia64_ptcl(vaddr, PAGE_SHIFT << 2); + perfc_incrc(domain_flush_vtlb_local); + } else { + /* ptc.ga has release semantics. */ + ia64_global_tlb_purge(vaddr, vaddr + PAGE_SIZE, PAGE_SHIFT); + perfc_incrc(domain_flush_vtlb_global); + } if (swap_rr0) { vcpu_set_rr(current, 0, old_rid); diff --git a/xen/include/asm-ia64/perfc_defn.h b/xen/include/asm-ia64/perfc_defn.h index ff1c2ef44b..40c0127c07 100644 --- a/xen/include/asm-ia64/perfc_defn.h +++ b/xen/include/asm-ia64/perfc_defn.h @@ -115,6 +115,8 @@ PERFCOUNTER_CPU(vcpu_flush_vtlb_all, "vcpu_flush_vtlb_all") PERFCOUNTER_CPU(domain_flush_vtlb_all, "domain_flush_vtlb_all") PERFCOUNTER_CPU(vcpu_flush_tlb_vhpt_range, "vcpu_flush_tlb_vhpt_range") PERFCOUNTER_CPU(domain_flush_vtlb_track_entry, "domain_flush_vtlb_track_entry") +PERFCOUNTER_CPU(domain_flush_vtlb_local, "domain_flush_vtlb_local") +PERFCOUNTER_CPU(domain_flush_vtlb_global, "domain_flush_vtlb_global") PERFCOUNTER_CPU(domain_flush_vtlb_range, "domain_flush_vtlb_range") // domain.c -- 2.30.2